package com.mocha.common.kits;

import cn.hutool.core.util.NumberUtil;

/**
 * @author: songkui
 * @date: 2023/2/23 15:17
 */
public class NumberKits extends NumberUtil {

    public static long parseLong(String number, long defaultValue) {
         try {
             return parseLong(number);
         }catch (Exception e){
             return defaultValue;
         }
    }

    public static boolean isMinus(Number number){
        return null == number || number.longValue() < 1 ? true : false;
    }

    public static boolean isNotMinus(Number number){
        return !isMinus(number);
    }


    /**
     * 0：表示前面补0
     * digit：表示保留数字位数
     * d：表示参数为正数类型
     */
    public static String fillString(int num , int digit, String prefix) {
        return String.format("%0"+digit+"d", num);
    }


}
